<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Notepad</title>

    <!-- bootstrap -->
    <link rel="stylesheet" href="./assets/css/bootstrap.min.css" />

    <!-- MUI -->
    <link rel="stylesheet" href="./assets/plugins/mui/css/mui.min.css" />

    <!-- animate.css -->
    <link rel="stylesheet" href="./assets/css/animate.min.css" />

    <!-- 重置样式 -->
    <link rel="stylesheet" href="./assets/css/reset.css" />

    <!-- 公共样式 -->
    <link rel="stylesheet" href="./assets/css/common.css" />

    <!-- 页面独立的 -->
    <link rel="stylesheet" href="./assets/css/ContactAdd.css" />

    <!-- jquery  -->
    <script src="./assets/js/jquery.min.js"></script>
</head>
<body>
    <!-- 信息录入 -->
    <div class="info">
        <h3 class="title wow fadeInUp">分类录入</h3>

        <p class="desc wow fadeInUp" data-wow-delay="200ms">
            您可在本页录入您的分类信息，录入成功后名片将会出现在首页。
        </p>
    </div>

    <form id="contact" class="contact wow fadeInUp" data-wow-delay="300ms">
        <div class="form-group">
            <label for="name">分类名称</label>
            <input type="text" class="form-control" name="name" id="name" placeholder="请输入分类名称" required />
        </div>
        
        <div class="action">
            <button type="submit" name="submit" class="btn">添加</button>
        </div>
    </form>
</body>
</html>
<!-- wow.js -->
<script src="./assets/js/wow.min.js"></script>

<!-- bootstrap -->
<script src="./assets/js/bootstrap.min.js"></script>

<!-- MUI -->
<script src="./assets/plugins/mui/js/mui.min.js"></script>

<!-- axios请求 -->
<script src="./assets/plugins/axios/axios.min.js"></script>
<script src="./assets/plugins/axios/request.js"></script>

<!-- cookie -->
<script src="./assets/plugins/cookie.js"></script>

<!-- 判断是否登录 -->
<script src="./assets/plugins/login.js"></script>
<script>
    //实例化wow.js
    new WOW().init()

    $('#contact').on('submit', async function(e){
        e.preventDefault()

        //获取当前登录信息
        var business = cookie.get('business') ? JSON.parse(cookie.get('business')) : {};

        //组装数据
        var data = {
            businessid: business.id,
            name: $.trim($('#name').val())
        }

        var result = await POST({
            url: '/card/type/add',
            params: data
        })

        if(result.code == 1)
        {
            mui.toast(result.msg, {duration: 1000})

            setTimeout(() => {
                location.href = 'TypeIndex.html'
            }, 500)
        }else
        {
            mui.toast(result.msg)
            return false
        }
    })
</script>